﻿using Arction.Wpf.Charting;
using Arction.Wpf.Charting.Axes;
using Arction.Wpf.Charting.Views.ViewXY;
using HighThroughput.ShareData;
using OSSUtility;
using OSSUtility.Charts;
using Ozone.Device;
using Ozone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ozone.Views.Curve
{
    /// <summary>
    /// UCAppCurve.xaml 的交互逻辑
    /// </summary>
    public partial class UCAppCurve : UserControl
    {
        int nDevIndex = 0;
     
        List<Button> lstSwitchButtons = new List<Button>();
        List<Grid> lstCurves = new List<Grid>();

        SolidColorBrush Brush_PurpleBackColor;
        SolidColorBrush Brush_MainBackColor;


        public UCAppCurve()
        {
            InitializeComponent();

            //找到资源 背景色
            var myResourceDictionaryShared = new ResourceDictionary
            {
                Source = new Uri("Resources/Styles/Shared.xaml", UriKind.RelativeOrAbsolute) // 指定样式文件的路径
                                                                                             //    Source = new Uri("Resources/Styles/Expander.xaml", UriKind.RelativeOrAbsolute) // 指定样式文件的路径
            };

            Brush_PurpleBackColor = myResourceDictionaryShared["Brush_PurpleBackColor"] as SolidColorBrush; // 通过key找到指定的样式
            Brush_MainBackColor = myResourceDictionaryShared["Brush_DarkBackColor3"] as SolidColorBrush; // 通过key找到指定的样式



            Init();

        }
    

        private void Init()
        {

            lstSwitchButtons.Add(btn0);
            lstSwitchButtons.Add(btn1);
            lstSwitchButtons.Add(btn2);
            lstSwitchButtons.Add(btn3);


        }

        private void btnSwitch_Click(object sender, RoutedEventArgs e)
        {
            SwitchButton(Utility.str2int(((Button)sender).Tag.ToString()));
        }

        private void SwitchButton(int nIndex)
        {
            for(int i=0;i<lstSwitchButtons.Count;i++)
            {
                if(i == nIndex)
                {
                    lstSwitchButtons[i].Background = Brush_PurpleBackColor;
                }
                else
                {
                    lstSwitchButtons[i].Background = Brush_MainBackColor ;
                }

            }

            SwitchCruvs(nIndex);
        }

        private void SwitchCruvs(int nIndex)
        {
            pageCurv.SwitchCharts(nIndex);
        }
    }


}
